using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
namespace Colorprj
{
    public partial class frmRptBuyerLedger : Form
    {
        public frmRptBuyerLedger()
        {
            InitializeComponent();
        }

        private void showToolStripMenuItem_Click(object sender, EventArgs e)
        {
            showReport(tsCboBuyer.ComboBox.SelectedValue);
        }
        private void showReport(object ButyerId)
        {

            ReportDocument cryRpt = new Report.BuyerLedger();

            ParameterField paramField = new ParameterField();
            ParameterFields paramFields = new ParameterFields();
            ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue();


            ParameterField paramField4 = new ParameterField();
            ParameterDiscreteValue paramDiscreteValue4 = new ParameterDiscreteValue();



            //Set instances for input parameter 1 -  @vDepartment
            paramField.Name = "@Buyerid";
            //Below variable can be set to any data present in SalseData table, Department column
            paramDiscreteValue.Value = ButyerId;
            paramField.CurrentValues.Add(paramDiscreteValue);
            //Add the paramField to paramFields
            paramFields.Add(paramField);

            paramField4.Name = "cName";

            //Below variable can be set to any data present in SalseData table, Department column
            paramDiscreteValue4.Value = Globalclass.CompanyName;
            paramField4.CurrentValues.Add(paramDiscreteValue4);
            //Add the paramField to paramFields
            paramFields.Add(paramField4);


            crystalReportViewer1.ParameterFieldInfo = paramFields;
            cryRpt.DataSourceConnections[0].SetConnection(Globalclass.DsnName, Globalclass.DbName, "atul", "vikas");
            cryRpt.SetDatabaseLogon("atul", "vikas", Globalclass.DsnName, Globalclass.DbName, false);
            crystalReportViewer1.ReportSource = cryRpt;

        }
        private void showAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            showReport(null);
        }

        private void frmRptBuyerLedger_Load(object sender, EventArgs e)
        {
            Colorprj.Masters.BuyerManager bm = new Colorprj.Masters.BuyerManager();
            tsCboBuyer.ComboBox.DataSource = bm.GetAllBuyers().Tables[0];
            tsCboBuyer.ComboBox.DisplayMember = "BuyerName";
            tsCboBuyer.ComboBox.ValueMember = "BuyerId";
        }

        private void toolStripSplitButton1_ButtonClick(object sender, EventArgs e)
        {

        }

        private void toolStripLabel1_Click(object sender, EventArgs e)
        {

        }
    }
}